<script setup lang="ts">
import { ref, reactive, computed, onMounted } from 'vue';

// 通过泛型定义 Prop
// key:参数名
// value:参数类型
// 可以定义为可选
// 可以通过返回值获取数据
const props = withDefaults(defineProps<{
  name: string
  age?: number
}>(),{
  age: 18888
})

const emit = defineEmits<{
  (e: 'changeAge',age:number): void
  (e: 'changeName',name:string): void
}>()

</script>

<template>
  <header class="header">
    <button v-on:click="emit('changeAge',666)">年龄修改为666🚀🚀🚀</button>
    <FyBtn></FyBtn>
    <span>{{ props.name }}&nbsp;&nbsp;</span>
    <span>{{ props.age }}</span>
    <div class="container">
      <div class="header-content">
        <div class="logo">
          <router-link to="/">
            <img src="../icons/IconCommunity.vue" alt="Logo" />
          </router-link>
        </div>
        <nav class="nav">
          <ul class="nav-list">
            <li class="nav-item">
              <router-link to="/">首页</router-link>
            </li>
            <li class="nav-item">
              <router-link to="/about">关于我们</router-link>
            </li>
            <li class="nav-item">
              <router-link to="/services">服务</router-link>
            </li>
            <li class="nav-item">
              <router-link to="/contact">联系我们</router-link>
            </li>
          </ul>
        </nav>
      </div>
    </div>
  </header>
</template>

<style scoped>
.header {
  background-color: #333;
  color: #fff;
  padding: 1rem 0;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo img {
  height: 40px;
}

.nav-list {
  list-style: none;
  display: flex;
  gap: 1rem;
}

.nav-item a {
  color: #fff;
  text-decoration: none;
  font-size: 1rem;
  padding: 0.5rem;
  transition: background-color 0.3s ease;
}

.nav-item a:hover {
  background-color: #555;
  border-radius: 4px;
}
</style>